library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ tibble  3.1.7     ✔ purrr   0.3.4
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(viridis)
## Loading required package: viridisLite
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
load("~/Documents/2022-DSPG-LivDiv-/data/livdivdata.RData")
fin_diary <- livdiv
#Weekly expenditure on clothes 

clothes_week <- fin_diary %>% select(village, week, aggregated_exp_clothes) %>% group_by(week, village) %>% summarize(avg_inc_clothes = mean(aggregated_exp_clothes, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(clothes_week, aes(week, avg_inc_clothes, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Average Income per week for clothes") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on books/tuition 

books_week <- fin_diary %>% select(village, week, exp_bookstuition) %>% group_by(week, village) %>% summarize(avg_bookstuition = mean(exp_bookstuition, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(books_week, aes(week, avg_bookstuition, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly expenditure on books/tuition") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on Utility 

utility_week <- fin_diary %>% select(village, week, exp_utility) %>% group_by(week, village) %>% summarize(avg_utility = mean(exp_utility, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(utility_week, aes(week, avg_utility, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Utilities") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on toiletries 

toilet_week <- fin_diary %>% select(village, week, exp_toiletries) %>% group_by(week, village) %>% summarize(avg_toilet = mean(exp_toiletries, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(toilet_week, aes(week, avg_toilet, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly expenditure on toiletries") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on durables 

durab_week <- fin_diary %>% select(village, week, exp_durables) %>% group_by(week, village) %>% summarize(avg_durables = mean(exp_durables, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(durab_week, aes(week, avg_durables, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Durable expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on health

health_week <- fin_diary %>% select(village, week, exp_health) %>% group_by(week, village) %>% summarize(avg_health = mean(exp_health, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(health_week, aes(week, avg_health, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly health expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on home repairs 

homerepairs_week <- fin_diary %>% select(village, week, exp_homerepairs) %>% group_by(week, village) %>% summarize(avg_homerepairs = mean(exp_homerepairs, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(homerepairs_week, aes(week, avg_homerepairs, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Homerepair Expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

#Weekly expenditure on transportation 

transport_week <- fin_diary %>% select(village, week, exp_transport) %>% group_by(week, village) %>% summarize(avg_transport = mean(exp_transport, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(transport_week, aes(week, avg_transport, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Transportation Expenditure", color = "Village") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

festivals_week <- fin_diary %>% select(village, week, exp_festivals) %>% group_by(week, village) %>% summarize(avg_festivals = mean(exp_festivals, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(festivals_week, aes(week, avg_festivals, color = village)) + geom_line() + labs(x = "", y = "Money (INR)", title = "Weekly Festival Expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

livestock_week <- fin_diary %>% select(village, week, exp_livestock) %>% group_by(week, village) %>% summarize(avg_livestock = mean(exp_livestock, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(livestock_week, aes(week, avg_livestock, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Livestock Expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

aginputs_week <- fin_diary %>% select(village, week, exp_aginputs) %>% group_by(week, village) %>% summarize(avg_aginputs = mean(exp_aginputs, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(aginputs_week, aes(week, avg_aginputs, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Agricultural Expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

labor_week <- fin_diary %>% select(village, week, exp_labor) %>% group_by(week, village) %>% summarize(avg_labor = mean(exp_labor, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(labor_week, aes(week, avg_labor, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Weekly Labor Expenditure") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?

nonfoodother_week <- fin_diary %>% select(village, week, exp_nonfoodother) %>% group_by(week, village) %>% summarize(avg_nonfoodother = mean(exp_nonfoodother, na.rm = TRUE))
## `summarise()` has grouped output by 'week'. You can override using the
## `.groups` argument.
ggplot(nonfoodother_week, aes(week, avg_nonfoodother, color = village)) + geom_line() + labs(x = "", y = "Income (INR)", title = "Other Weekly Expenditure(non-cosumption)") + scale_x_discrete(breaks = c(10,20,30,40), labels = c("January 2019", "April 2019", "July 2019", "October 2019"), limits = 10:40) 
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?